//========================================================================
// *作者：海盗猫  主页：ilplay.com
// *脚本：ExcelText
// *描述：
// *?2021 MYJL . All rights reserved.
//* ======================================================================

using System;
using UnityEngine;
using UnityEngine.UI;

namespace HDMCode.Excel
{
	[Serializable]
	public struct ExcelType
	{
		public string XlslName;
        public string SheetName;
        public string ID;
    }
	public class HDMText : Text
	{
        [SerializeField] private ExcelType _excelType;

        [HideInInspector]
        public override string text => GetExecelString();

        public static string country { get; set; }

        public string GetExecelString() 
        {
            if (!string.IsNullOrEmpty(_excelType.XlslName) && !string.IsNullOrEmpty(_excelType.SheetName) && !string.IsNullOrEmpty(_excelType.ID))
            {
                string readText = HDMExcelRead.ReadSheel(_excelType.XlslName, _excelType.SheetName, _excelType.ID, country);
                if (readText != "null")
                {
                    return readText;
                }
                else
                {
                    return base.text;
                }
            }
            else 
            {
                return base.text;
            }
        }

        /// <summary>
        /// 设置国家信息
        /// </summary>
        [RuntimeInitializeOnLoadMethod]
        public static void SetCountry()
        {
            country = Application.systemLanguage.ToString();
        }

    }
}


